package com.fintech.third.service.bairong;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fintech.common.enums.RespStatus;
import com.fintech.common.service.BaseServiceImpl;
import com.fintech.common.util.ApiResponse;
import com.fintech.datagroud.dao.bairong.EdcBRDataQueryLogInfoMapper;
import com.fintech.datagroud.dao.bairong.EdcBrCreditRiskEvaluationMapper;
import com.fintech.datagroud.entity.bairong.EdcBrCreditRiskEvaluation;
import com.fintech.third.constant.ThirdMethodConstants;
import com.fintech.third.model.EquipmentInfor;
import com.fintech.third.model.ThirdEffectDTO;
import com.fintech.third.model.bairong.AirTravelLevel;
import com.fintech.third.model.bairong.Applications;
import com.fintech.third.model.bairong.BadInformation;
import com.fintech.third.model.bairong.BankcardCheck;
import com.fintech.third.model.bairong.BankcardCheckThree;
import com.fintech.third.model.bairong.BddPackAllInterfaceInfo;
import com.fintech.third.model.bairong.BizInfo;
import com.fintech.third.model.bairong.BizInfoKey;
import com.fintech.third.model.bairong.BizInvest;
import com.fintech.third.model.bairong.BizInvestMap;
import com.fintech.third.model.bairong.ConsumAbbility;
import com.fintech.third.model.bairong.CreditRiskEvaluation;
import com.fintech.third.model.bairong.CurrentEquipmentInformationReport;
import com.fintech.third.model.bairong.CurrentEquipmentPackageInfo;
import com.fintech.third.model.bairong.DishonestEnterprise;
import com.fintech.third.model.bairong.DishonestExecutor;
import com.fintech.third.model.bairong.EdcBRDataQueryLogInfo;
import com.fintech.third.model.bairong.EductionInformation;
import com.fintech.third.model.bairong.EquipmentInfo;
import com.fintech.third.model.bairong.EquipmentSpecialList;
import com.fintech.third.model.bairong.IdCardCheck;
import com.fintech.third.model.bairong.IncomeLevel;
import com.fintech.third.model.bairong.IncomeMonthLevel;
import com.fintech.third.model.bairong.LoanFacilityInformation;
import com.fintech.third.model.bairong.LoanFacilityPackageInfo;
import com.fintech.third.model.bairong.LoginFacilityInformation;
import com.fintech.third.model.bairong.LoginFacilityPackageInfo;
import com.fintech.third.model.bairong.MediaReading;
import com.fintech.third.model.bairong.MicroCreditLevel;
import com.fintech.third.model.bairong.MicroPaymentConsum;
import com.fintech.third.model.bairong.MultipleApplications;
import com.fintech.third.model.bairong.PayBehavior;
import com.fintech.third.model.bairong.PaymentConsum;
import com.fintech.third.model.bairong.PerInvest;
import com.fintech.third.model.bairong.ReceiveAndConsumLevel;
import com.fintech.third.model.bairong.RegisterFacilityInformation;
import com.fintech.third.model.bairong.RegisterFacilityPackageInfo;
import com.fintech.third.model.bairong.RuleInformation;
import com.fintech.third.model.bairong.Score;
import com.fintech.third.model.bairong.SocietyRelation;
import com.fintech.third.model.bairong.SpecialList;
import com.fintech.third.model.bairong.Stability;
import com.fintech.third.model.bairong.TelCheck;
import com.fintech.third.model.bairong.TelStatus;
import com.fintech.third.model.bairong.TelTwoInformation;
import com.fintech.third.model.bairong.VehicleViolation;
import com.marvels.common.utils.MarvelsLogUtil;

import net.sf.json.JSONObject;

/**
 * 百融数据（时效性）
 * 
 * @title FreshBaiRongImpl
 * @author tuxu
 * @date 2018年9月25日
 */
@SuppressWarnings("unchecked")
@Service("freshBaiRong")
public class FreshBaiRongImpl extends BaseServiceImpl implements BaiRongService {

	@Autowired
	private EdcBrCreditRiskEvaluationMapper edcBrCreditRiskEvaluationMapper;
	@Autowired
	private EdcBRDataQueryLogInfoMapper edcBRDataQueryLogInfoMapper;

	@Autowired(required = true)
	private BaiRongService BaiRong;

	/**
	 * 通用方法，对时效性各个状态进行处理<BR>
	 * 仅适用于返回数据类型是ApiResponse的场景
	 * 
	 * @param json
	 *            业务参数，直接查询接口时透传
	 * @param serialNum
	 *            请求唯一编号
	 * @param loanId
	 *            贷款编号
	 * @param channel
	 *            渠道类型：比如电脑，手机等
	 * @param interfaceCode
	 *            接口编码
	 * @return
	 */
	private ApiResponse<?> dealCommon(JSONObject json, String serialNum, String loanId, String channel,
			String interfaceCode) {
		MarvelsLogUtil.getInstance().info("======dealCommon json:" + json + " serialNum:" + serialNum + " loanId:" + loanId
				+ " interfaceCode:" + interfaceCode);
		ApiResponse<?> apiResponse = new ApiResponse<>();
		// 获取时效性相关数据
		ThirdEffectDTO effectDto = new ThirdEffectDTO();
		// 实时查询
		if (QUERY_REALTIME.equals(effectDto.getEffectFlag())) {
			return queryDirect(json, serialNum, loanId, channel, interfaceCode);
		}
		// 接口停用
		if (QUERY_STOP.equals(effectDto.getEffectFlag())) {
			apiResponse.setCode(RespStatus.DISABLE.getCode());
			apiResponse.setMsg(RespStatus.DISABLE.getMsg());
			return apiResponse;
		}
		// 需要重新查询，并且时效性中间表要记录结果数据
		if (QUERY_REALTIME_AND_IN_RECORDS.equals(effectDto.getEffectFlag())) {
			apiResponse = queryDirect(json, serialNum, loanId, channel, interfaceCode);
			// 查询成功，中间表需要插入数据
			if (apiResponse.getCode() == RespStatus.SUCCESS.getCode()) {
				saveEdcDataCallOperationRecords(effectDto);
			}
			return apiResponse;
		}
		// 无需重新查询，取历史数据
		if (QUERY_HISTORY.equals(effectDto.getEffectFlag())) {
			apiResponse = getData(effectDto);
			apiResponse.setCode(RespStatus.SUCCESS.getCode());
			apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
			return apiResponse;
		}
		return apiResponse;
	}

	/**
	 * 通用方法，对时效性各个状态进行处理<BR>
	 * 仅适用于返回数据类型是ApiResponse的场景
	 * 
	 * @param reqMap
	 *            业务参数，直接查询接口时透传
	 * @param serialNum
	 *            请求唯一编号
	 * @param loanId
	 *            贷款编号
	 * @param channel
	 *            渠道类型：比如电脑，手机等
	 * @param interfaceCode
	 *            接口编码
	 * @return
	 */
	private ApiResponse<?> dealCommon(Map<String, String> reqMap, String interfaceCode) {
		MarvelsLogUtil.getInstance().info("======dealCommon reqMap:" + reqMap + " interfaceCode:" + interfaceCode);
		ApiResponse<?> apiResponse = new ApiResponse<>();
		
		// 获取时效性相关数据
		ThirdEffectDTO effectDto = new ThirdEffectDTO();
		effectDto.setCustIdCard(reqMap.get("custIdCard"));
		effectDto.setInterfaceCode(interfaceCode);
		effectDto.setLoanId(reqMap.get("loanId"));
		effectDto.setProductType(reqMap.get("productType"));
		effectDto.setMobileNo(reqMap.get("mobile"));
		effectDto = checkEffectInfo(effectDto);
		// 实时查询
		if (QUERY_REALTIME.equals(effectDto.getEffectFlag())) {
			return queryDirect(reqMap, interfaceCode);
		}
		// 接口停用
		if (QUERY_STOP.equals(effectDto.getEffectFlag())) {
			apiResponse.setCode(RespStatus.DISABLE.getCode());
			apiResponse.setMsg(RespStatus.DISABLE.getMsg());
			return apiResponse;
		}
		// 需要重新查询，并且时效性中间表要记录结果数据
		if (QUERY_REALTIME_AND_IN_RECORDS.equals(effectDto.getEffectFlag())) {
			apiResponse = queryDirect(reqMap, interfaceCode);
			// 查询成功，中间表需要插入数据
			if (apiResponse.getCode() == RespStatus.SUCCESS.getCode()) {
				saveEdcDataCallOperationRecords(effectDto);
			}
			return apiResponse;
		}
		// 无需重新查询，取历史数据
		if (QUERY_HISTORY.equals(effectDto.getEffectFlag())) {
			apiResponse = getData(effectDto);
			apiResponse.setCode(RespStatus.SUCCESS.getCode());
			apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
			return apiResponse;
		}
		return apiResponse;
	}

	private ApiResponse<?> getData(ThirdEffectDTO effectDto) {
		if (ThirdMethodConstants.BR0055.equals(effectDto.getInterfaceCode())) {
			ApiResponse<CreditRiskEvaluation> apiResponse = new ApiResponse<CreditRiskEvaluation>();
			// 有调用记录直接去查历史loanid的评估分数
			EdcBrCreditRiskEvaluation edcBrCreditRiskEvaluation = edcBrCreditRiskEvaluationMapper
					.selectByLoanIdReturnOne(effectDto.getEffectLoanId());
			CreditRiskEvaluation creditRiskEvaluation = new CreditRiskEvaluation();
			if (edcBrCreditRiskEvaluation != null) {
				creditRiskEvaluation.setSwift_number(edcBrCreditRiskEvaluation.getSwiftNumber());
				creditRiskEvaluation.setCode(edcBrCreditRiskEvaluation.getCode());
				creditRiskEvaluation.setFlag_score(edcBrCreditRiskEvaluation.getFlagScore());
				creditRiskEvaluation.setScorelargecashv2(edcBrCreditRiskEvaluation.getScorelargecashv2());
				creditRiskEvaluation.setId_number(edcBrCreditRiskEvaluation.getIdNumber());
				creditRiskEvaluation.setCell(edcBrCreditRiskEvaluation.getCell());
				creditRiskEvaluation.setUser_name(edcBrCreditRiskEvaluation.getUserName());
				apiResponse.setData(creditRiskEvaluation);
			}
			return apiResponse;
		}
		return new ApiResponse<>();
	}

	private ApiResponse<?> queryDirect(Map<String, String> reqMap, String interfaceCode) {
		if (ThirdMethodConstants.BR0049.equals(interfaceCode)) {
			return BaiRong.loginFacilityInformationReportPack(reqMap);
		}
		if (ThirdMethodConstants.BR0050.equals(interfaceCode)) {
			return BaiRong.loanFacilityInformationReportPack(reqMap);
		}
		if (ThirdMethodConstants.BR0051.equals(interfaceCode)) {
			return BaiRong.registerFacilityInformationReportPack(reqMap);
		}
		if (ThirdMethodConstants.BR0052.equals(interfaceCode)) {
			return BaiRong.cashFacilityInformationReportPack(reqMap);
		}
		return new ApiResponse<>();
	}

	private ApiResponse<?> queryDirect(JSONObject json, String serialNum, String loanId, String channel,
			String interfaceCode) {
		if (ThirdMethodConstants.BR0001.equals(interfaceCode)) {
			return BaiRong.specialListReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0002.equals(interfaceCode)) {
			return BaiRong.multipleApplicationsReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0003.equals(interfaceCode)) {
			return BaiRong.stabilityReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0004.equals(interfaceCode)) {
			return BaiRong.incomeLevelReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0005.equals(interfaceCode)) {
			return BaiRong.loanFacilityInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0006.equals(interfaceCode)) {
			return BaiRong.registerFacilityInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0007.equals(interfaceCode)) {
			return BaiRong.loginFacilityInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0008.equals(interfaceCode)) {
			return BaiRong.cashFacilityInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0009.equals(interfaceCode)) {
			return BaiRong.dishonestExecutorReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0010.equals(interfaceCode)) {
			return BaiRong.dishonestEnterpriseReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0011.equals(interfaceCode)) {
			return BaiRong.badInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0012.equals(interfaceCode)) {
			return BaiRong.telTwoInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0013.equals(interfaceCode)) {
			return BaiRong.telCheckReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0014.equals(interfaceCode)) {
			return BaiRong.vehicleViolationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0015.equals(interfaceCode)) {
			return BaiRong.eductionInformationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0016.equals(interfaceCode)) {
			return BaiRong.idCardCheckReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0017.equals(interfaceCode)) {
			return BaiRong.bankcardCheckReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0018.equals(interfaceCode)) {
			return BaiRong.consumAbbilityReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0019.equals(interfaceCode)) {
			return BaiRong.mediaReadingReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0020.equals(interfaceCode)) {
			return BaiRong.receiveAndConsumLevelReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0021.equals(interfaceCode)) {
			return BaiRong.microCreditLevelReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0022.equals(interfaceCode)) {
			return BaiRong.paymentConsumReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0023.equals(interfaceCode)) {
			return BaiRong.microPaymentConsumReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0024.equals(interfaceCode)) {
			return BaiRong.payBehaviorReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0025.equals(interfaceCode)) {
			return BaiRong.societyRelationReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0026.equals(interfaceCode)) {
			return BaiRong.airTravelLevelReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0027.equals(interfaceCode)) {
			return BaiRong.telStatusReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0028.equals(interfaceCode)) {
			return BaiRong.perInvestReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0029.equals(interfaceCode)) {
			return BaiRong.bizInfoReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0030.equals(interfaceCode)) {
			return BaiRong.bizInvestReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0031.equals(interfaceCode)) {
			return BaiRong.bizInfoKeyReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0032.equals(interfaceCode)) {
			return BaiRong.bizInvestMapReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0033.equals(interfaceCode)) {
			return BaiRong.scoreReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0034.equals(interfaceCode)) {
			return BaiRong.incomeMonthLevelReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0035.equals(interfaceCode)) {
			return BaiRong.ruleReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0036.equals(interfaceCode)) {
			return BaiRong.equipmentInformationVerification(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0037.equals(interfaceCode)) {
			return BaiRong.equipmentSpecialListInfo(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0038.equals(interfaceCode)) {
			return BaiRong.equipmentInfo(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0039.equals(interfaceCode)) {
			return BaiRong.bankcardCheckThreeReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0042.equals(interfaceCode)) {
			return BaiRong.applicationsReport(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0047.equals(interfaceCode)) {
			return BaiRong.packgeAllInterfaceInfo(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0048.equals(interfaceCode)) {
			return BaiRong.packgeAllBrInterfaceInfoForMall(json, serialNum, loanId, channel);
		}
		if (ThirdMethodConstants.BR0055.equals(interfaceCode)) {
			return BaiRong.queryCreditRiskEvaluation(json, serialNum, loanId, channel);
		}
		return new ApiResponse<>();
	}

	@Override
	public ApiResponse<SpecialList> specialListReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<SpecialList>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0001);
	}

	/**
	 * 多次申请核查v2(用户近7/15天、1/3/6个月在百融的虚拟信贷联盟(银行、非银、非银细分类型)中的多次信贷申请情况)
	 * 
	 * @param json
	 * @return
	 */
	public ApiResponse<MultipleApplications> multipleApplicationsReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<MultipleApplications>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0002);
	}

	public ApiResponse<Stability> stabilityReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<Stability>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0003);
	}

	public ApiResponse<IncomeLevel> incomeLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<IncomeLevel>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0004);
	}

	public ApiResponse<LoanFacilityInformation> loanFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<LoanFacilityInformation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0005);
	}

	public ApiResponse<RegisterFacilityInformation> registerFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<RegisterFacilityInformation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0006);
	}

	public ApiResponse<LoginFacilityInformation> loginFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<LoginFacilityInformation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0007);
	}

	public ApiResponse<CurrentEquipmentInformationReport> cashFacilityInformationReport(JSONObject json,
			String serialNum, String loanId, String channel) {
		return (ApiResponse<CurrentEquipmentInformationReport>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0008);
	}

	public ApiResponse<DishonestExecutor> dishonestExecutorReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<DishonestExecutor>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0009);
	}

	public ApiResponse<DishonestEnterprise> dishonestEnterpriseReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<DishonestEnterprise>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0010);
	}

	public ApiResponse<BadInformation> badInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<BadInformation>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0011);
	}

	public ApiResponse<TelTwoInformation> telTwoInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<TelTwoInformation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0012);
	}

	public ApiResponse<TelCheck> telCheckReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<TelCheck>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0013);
	}

	public ApiResponse<VehicleViolation> vehicleViolationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<VehicleViolation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0014);
	}

	public ApiResponse<EductionInformation> eductionInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<EductionInformation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0015);
	}

	public ApiResponse<IdCardCheck> idCardCheckReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<IdCardCheck>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0016);
	}

	public ApiResponse<BankcardCheck> bankcardCheckReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<BankcardCheck>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0017);
	}

	public ApiResponse<ConsumAbbility> consumAbbilityReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<ConsumAbbility>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0018);
	}

	public ApiResponse<MediaReading> mediaReadingReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<MediaReading>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0019);
	}

	public ApiResponse<ReceiveAndConsumLevel> receiveAndConsumLevelReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<ReceiveAndConsumLevel>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0020);
	}

	public ApiResponse<MicroCreditLevel> microCreditLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<MicroCreditLevel>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0021);
	}

	public ApiResponse<PaymentConsum> paymentConsumReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<PaymentConsum>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0022);
	}

	public ApiResponse<MicroPaymentConsum> microPaymentConsumReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<MicroPaymentConsum>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0023);
	}

	public ApiResponse<PayBehavior> payBehaviorReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<PayBehavior>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0024);
	}

	public ApiResponse<SocietyRelation> societyRelationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<SocietyRelation>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0025);
	}

	public ApiResponse<AirTravelLevel> airTravelLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<AirTravelLevel>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0026);
	}

	public ApiResponse<TelStatus> telStatusReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<TelStatus>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0027);
	}

	public ApiResponse<PerInvest> perInvestReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<PerInvest>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0028);
	}

	public ApiResponse<BizInfo> bizInfoReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<BizInfo>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0029);
	}

	public ApiResponse<BizInvest> bizInvestReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<BizInvest>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0030);
	}

	public ApiResponse<BizInfoKey> bizInfoKeyReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<BizInfoKey>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0031);
	}

	public ApiResponse<BizInvestMap> bizInvestMapReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<BizInvestMap>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0032);
	}

	public ApiResponse<Score> scoreReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<Score>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0033);
	}

	public ApiResponse<IncomeMonthLevel> incomeMonthLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<IncomeMonthLevel>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0034);
	}

	public ApiResponse<RuleInformation> ruleReport(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<RuleInformation>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0035);
	}

	@Override
	public ApiResponse<EquipmentInfor> equipmentInformationVerification(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<EquipmentInfor>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0036);
	}

	@Override
	public ApiResponse<EquipmentSpecialList> equipmentSpecialListInfo(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<EquipmentSpecialList>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0037);
	}

	@Override
	public ApiResponse<EquipmentInfo> equipmentInfo(JSONObject json, String serialNum, String loanId, String channel) {
		return (ApiResponse<EquipmentInfo>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0038);
	}

	@Override
	public ApiResponse<BankcardCheckThree> bankcardCheckThreeReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<BankcardCheckThree>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0039);
	}

	@Override
	public ApiResponse<Applications> applicationsReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<Applications>) dealCommon(json, serialNum, loanId, channel, ThirdMethodConstants.BR0042);
	}

	@Override
	public ApiResponse<BddPackAllInterfaceInfo> packgeAllInterfaceInfo(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<BddPackAllInterfaceInfo>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0047);
	}

	@Override
	public ApiResponse<LoanFacilityPackageInfo> loanFacilityInformationReportPack(Map<String, String> reqMap) {
		return (ApiResponse<LoanFacilityPackageInfo>) dealCommon(reqMap, ThirdMethodConstants.BR0050);
	}

	@Override
	public ApiResponse<RegisterFacilityPackageInfo> registerFacilityInformationReportPack(Map<String, String> reqMap) {
		return (ApiResponse<RegisterFacilityPackageInfo>) dealCommon(reqMap, ThirdMethodConstants.BR0051);
	}

	@Override
	public ApiResponse<LoginFacilityPackageInfo> loginFacilityInformationReportPack(Map<String, String> reqMap) {
		return (ApiResponse<LoginFacilityPackageInfo>) dealCommon(reqMap, ThirdMethodConstants.BR0049);
	}

	@Override
	public ApiResponse<CurrentEquipmentPackageInfo> cashFacilityInformationReportPack(Map<String, String> reqMap) {
		return (ApiResponse<CurrentEquipmentPackageInfo>) dealCommon(reqMap, ThirdMethodConstants.BR0052);
	}

	@Override
	public ApiResponse<BddPackAllInterfaceInfo> packgeAllBrInterfaceInfoForMall(JSONObject json, String serialNum,
			String loanId, String channel) {
		return (ApiResponse<BddPackAllInterfaceInfo>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0048);
	}

	/**
	 * 查询信用风险识别分数
	 */
	@Override
	public ApiResponse<CreditRiskEvaluation> queryCreditRiskEvaluation(JSONObject json, String serialNum, String loanId,
			String channel) {
		return (ApiResponse<CreditRiskEvaluation>) dealCommon(json, serialNum, loanId, channel,
				ThirdMethodConstants.BR0055);
	}

	/**
	 * 根据loanId查询百融数据
	 * 
	 * @param loanId)
	 * @return
	 */
	@Override
	public List<EdcBRDataQueryLogInfo> findEdcBRDataQueryLogInfo(String loanId) {
		List<EdcBRDataQueryLogInfo> logInfos = edcBRDataQueryLogInfoMapper.findEdcBRDataByLoanId(loanId);
		return logInfos;
	}

}
